#ifndef DATE_H
#define DATE_H
//  File:	 Date.h
//  Author:  Scott Nordmann & Lauren Wallace
//  Description:  A class definition for the Date.
#include "Event.h"
#include <fstream>
#include <string>
#include <vector>

class Date
{
public:
	// Constructors
	Date(); // by default, a Date is initialized with today's date
	Date(const Date& d);
	Date(int y, int mo, int d, int w = -1);

	// Destructor
	~Date();

	void shutDown(std::ofstream& ofsave);

	// Accessors
	int getYear() const;
	int getMonth() const;
	int getDay() const;
	int getWeekDay() const;
	std::string getDateString() const;

	// Mutators
	void setYear(int y);
	void setMonth(int m);
	void setDay(int d);
	void setWeekDay(int w);

	// Events
	bool hasEvents() const;
	void addEvent(Event* e);
	void deleteEvent(Event* e);
	Event* findEvent(const std::string& eventTitle);
	Event* viewSpecificEvent() const;

	// Display
	void display() const;
	void displayEvents() const;

	// Increment/Decrement
	void incrementDay(int numDays = 1);
	void decrementDay(int numDays = 1);

	// Utilities
	static int getDaysInMonth(int month, int year = 0);
	static std::string getWeekDayName(int weekDay);
	static Date parseDate(const std::string& dateString);

	// Operators
	bool Date::operator==(const Date& d) const;
	bool Date::operator!=(const Date& d) const;
	bool Date::operator<(const Date& d) const;
	bool Date::operator>(const Date& d) const;

private:
	int year;
	int month;
	int day;
	int weekDay;
	std::vector<Event*> events;
};

inline int Date::getYear() const { return year; }
inline int Date::getMonth() const { return month; }
inline int Date::getDay() const { return day; }
inline int Date::getWeekDay() const { return weekDay; }

inline void Date::setYear(const int y) { year = y; }
inline void Date::setMonth(const int m) { month = m; }
inline void Date::setDay(const int d) { day = d; }
inline void Date::setWeekDay(const int w) { weekDay = w; }

inline bool Date::operator==(const Date& d) const
{
	return (getYear() == d.getYear() &&
			getMonth() == d.getMonth() &&
			getDay() == d.getDay());
}

inline bool Date::operator!=(const Date& d) const
{
    return !(*this == d);
}

inline bool Date::operator<(const Date& d) const
{
	return (getYear()  < d.getYear()  ? true :
			getMonth() < d.getMonth() ? true :
			getDay()   < d.getDay()   ? true : false);
}

inline bool Date::operator>(const Date& d) const
{
    return !(*this < d || *this == d);
}

inline bool Date::hasEvents() const
{
	return !events.empty();
}

#endif
